﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RoccaStore.Data.Entity.Model;

namespace RoccaStore.Data.Entity.Entities
{
    public class AccountEntities : EntitiesBase<RoccaStoreEntities>, IAccountRepository
    {
        public Account GetByID(int id)
        {
            return Context.Account.FirstOrDefault(a => a.ID == id);
        }

        public Account GetByEmail(string email)
        {
            return Context.Account.FirstOrDefault(a => a.Email == email);
        }

        public Account GetByFacebookID(string facebookId)
        {
            return Context.Account.FirstOrDefault(a => a.FacebookUserID == facebookId);
        }

        public List<Account> GetAll()
        {
            return Context.Account.ToList();
        }

        public int Save(Account account)
        {
            Context.Account.Add(account);
            Context.SaveChanges();
            return account.ID;
        }
    }
}
